package com.xiao.controller;

import com.xiao.entity.EmployeeEntity;
import com.xiao.entity.UserEntity;
import com.xiao.mapper.EmployeeMapper;
import com.xiao.mapper.UserMapper;
import org.apache.ibatis.annotations.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @_PackageName:com.xiao.controller
 * @_ClassName:EmployeeController
 * @_Description:
 * @_Author：笑老二
 * @_data 2020/12/12 20:56
 */
@RestController //直接返回json数据
public class EmployeeController {

    @Autowired
    EmployeeMapper employeeMapper;

    @Autowired
    UserMapper userMapper;

    @GetMapping("/employee/{eid}")
    public EmployeeEntity findOneByEid(@PathVariable Integer eid) {
        return employeeMapper.findOneByEid(eid);
    }

    @GetMapping("/dept")
    public EmployeeEntity insert(EmployeeEntity employeeEntity) {
        employeeMapper.insert(employeeEntity);
        return employeeEntity;
    }

    @GetMapping("/user/{uid}")
    public UserEntity findOne(@PathVariable int uid) {
        return userMapper.findOne(uid);
    }

}
